<template>
    <div class="box">
        <el-row>
            <el-col :span="22" :push="1">
                <div class="grid-content bg-purple">
                    <div class="kuang"></div>
                    <div class="box_text">
                        {{ title }}
                        <el-divider></el-divider>
                    </div>
                    <div style="margin-top: 20px; margin-left: 40px; width: 500px">
                        <el-form label-position="right" label-width="100px">
                            <el-form-item label="案库号">
                                <el-input v-model="form.caselockerId" placeholder="案库号"
                                    style="width: 220px;"></el-input>
                            </el-form-item>
                            <el-form-item label="案库名">
                                <el-input v-model="form.caselockerName" placeholder="案库名"
                                    style="width: 220px;"></el-input>
                            </el-form-item>
                            <el-form-item label="所属全宗">
                                <el-select v-model="form.recordId" >
                                        <el-option v-for="(item ,index) in carNumbers" @click.native ="fuzhi(index)" :key="item.id" :label="item.recordCompany"
                                            :value="item.id">
                                        </el-option>
                                    </el-select>
                            </el-form-item>
                            <el-form-item label="全宗号">
                                <el-input v-model="form.rid" placeholder="全宗号"
                                    style="width: 220px;" disabled></el-input>
                            </el-form-item>
                            <el-form-item label="所属公司">
                                <el-input v-model="form.recordCompany" placeholder="所属公司"
                                    style="width: 220px;" disabled></el-input>
                            </el-form-item>
                        </el-form>
                        <el-button type="primary" @click="onSubmit">立即提交</el-button>
                        <el-button @click="back">取消</el-button>
                    </div>
                    
                </div>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import axios from "axios";
export default {
    data() {
        return {
            form: {
                createUser: JSON.parse(localStorage.getItem("user")).id
            },
            options: {},
            title: "新建案库",
            carNumbers: {},
            etcIds:{},
            upheaders: {
                Authorization: "Bearer" + localStorage.getItem("token"),
            },
            radio:"",
        };
    },
    created() {
        this.getCarNumber()
        if (this.$route.query.id != undefined) {
            this.title = "修改案库"
            this.echoCarcheer()
        }
    },
    methods: {
        fuzhi(val){
            var data = this.carNumbers[val]
            this.$set(this.form,"rid", data.recordId)
            this.form.recordCompany = data.recordCompany
        },
        //回显
        echoCarcheer() {
            axios.post("recordcaselocker/echorecordcaselocker?id=" + this.$route.query.id).then((res) => {
                console.log(res.data.data)
                this.form = res.data.data
            })
        },
        //提交
        onSubmit() {
            if (this.$route.query.id == undefined) {
                axios.post("recordcaselocker/addrecordcaselocker", this.form).then((res) => {
                    if (res.data.code === 200) {
                        this.$message.success(res.data.data)
                        this.form = {}
                        this.$router.go(-1)
                    }
                })
            } else {
                this.form.id = this.$route.query.id
                axios.post("recordcaselocker/uprecordcaselocker", this.form).then((res) => {
                    if (res.data.code === 200) {
                        this.$message.success(res.data.data)
                        this.form = {}
                        this.$router.go(-1)
                    }
                })
            }
        },
        //查询指定信息
        getCarNumber() {
            axios.get("/record/findselect").then((res) => {
                this.carNumbers = res.data.data;
            });
        },
        // 返回上一页
        back() {
            this.$router.go(-1)
        },
    }
};
</script>

<style scoped>
/* element-ui样式 */
.el-row {
    margin-bottom: 10px;

    &:last-child {
        margin-bottom: 0;
    }
}

.el-col {
    border-radius: 4px;
}

.bg-purple {
    background: #fff;
    border-radius: 10px;
}

/* 自定义样式 */
/* * {
      margin: 0px;
      padding: 0px;
    } */
.box {
    width: 98%;
    height: 100%;
    margin: auto;
    /* background-color: red; */
}

.box_text {
    padding-top: 20px;
    /* padding-left: 40px; */
    margin-left: 40px;
    font-size: 13px;
}

/* 获取负责人start */
.avatar-uploader-icon[data-v-0bfb98ce] {
    border: 1px solid rgba(198, 201, 208, 1);
    background-color: rgba(248, 248, 248, 1);
    border-radius: 50%;
}

.avatar-uploader-icon {
    font-size: 20px;
    color: #8c939d;
    width: 50px;
    height: 50px;
    line-height: 50px;
    text-align: center;
}


.architecture {
    width: 271px;
    height: 39px;
    padding-left: 20px;
    border-radius: 5px;
}

.architecture:hover {
    background-color: #f8f8f8;
}

.architectureActe {
    width: 271px;
    height: 39px;
    line-height: 39px;
    padding-left: 20px;
    border-radius: 5px;
    background-color: rgba(231, 244, 255, 1);
    ;
}

/* 竖着的水平线 */
.myHr {
    border-left: 2px solid#989DAA;
    ;
    height: 100%;
    left: 48%;
    top: 0px;
    position: absolute;
}

.log {
    width: 27px;
    height: 27px;
    background-color: rgba(158, 208, 255, 1);
    float: left;
    position: relative;
    top: 15%;
    border-radius: 50%;
}

.log img {
    width: 13px;
    height: 13px;
    position: relative;
    bottom: 15%;
    left: 25%;
}

/* 获取负责人end */
.kuang {
    width: 4.5px;
    height: 25px;
    background-color: #409EFF;
    margin-left: 30px;
    position: relative;
    top: 43px;
}
</style>